import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '',
    redirect: '/construction', //重定向   默认首页
  },
  {
    path: '/construction',
    name: 'construction',
    component: () => import('../views/construction/index.vue')
  },
  {
    path: '/management',
    name: 'management',
    component: () => import('../views/management/index.vue')
  },
  ,
  {
    path: '/vtour',
    name: 'vtour',
    component: () => import('../views/vtour/index.vue')
  }
]

// 防止连续点击多次路由报错
let routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
